package com.shengwei.truck.driver.vm;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import com.shengwei.truck.driver.bean.JsonTrackData;
import com.shengwei.truck.driver.bean.Result;
import com.shengwei.truck.driver.model.DataSource;
import com.shengwei.truck.driver.model.Repository;

public class TrackViewModel extends ViewModel {
    private Repository mRepository; //M层引用
    MutableLiveData<Result<JsonTrackData>> mTrackLiveData = new MutableLiveData<>();
    public TrackViewModel(Repository repository) {
        mRepository = repository;
    }
    public TrackViewModel() {
        mRepository = Repository.getInstance(DataSource.getSingleInstance());
    }

    public MutableLiveData<Result<JsonTrackData>> getTrackLiveData() {
        return mTrackLiveData;
    }

    /**
     * 获取当前任务的位置轨迹
     * @param taskId
     * @param startTime
     * @param endTime
     */
    public void getTrack(String taskId,long startTime,long endTime) {
        mRepository.getTrack(taskId,startTime,endTime,mTrackLiveData);
    }
}
